<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<title>门店列表</title>
<link rel="stylesheet" type="text/css"
	href="/css/reset.css" />
<link rel="stylesheet" type="text/css"
	href="/css/common.css" />
<link rel="stylesheet" type="text/css"
	href="/css/thems.css">
<link rel="stylesheet" type="text/css"
	href="/css/color.css" />
<link rel="stylesheet" type="text/css"
	href="/css/bootStrap.min.css" />

<script type="text/javascript"
	src="/js/jquery-3.2.1.js"></script>
		<script type="text/javascript">
			$(function() {
				//自适应屏幕宽度
				window.onresize = function() {
					location = location
				};

				var main_h = $(window).height();
				$('.hy_list').css('height', main_h - 45 + 'px');

				var search_w = $(window).width() - 40;
				$('.search').css('width', search_w + 'px');
				//$('.list_hy').css('width',search_w+'px');
			});
		</script>
		<!--框架高度设置-->
	</head>

	<body>
		<div id="right_ctn ">
			<div class="right_m ">
				<!--会议列表-->
				<div class="hy_list ">
					<div class="box_t ">
						<span class="name ">优惠卷列表</span>
						
					</div>
					<!--查询-->
					<form action="/jump/selectGrabtheAll" class="navbar-form navbar-left" method="post ">
						
						&nbsp;&nbsp;
						<select class="form-control testselect" name="codeId">
						<option value="0">请选择优惠卷类型</option>
						<#list codeList as list>
						<#if list.valueId ==codeId>
						<option selected value="${list.valueId}">${list.valueName}</option>
						<#else>
						<option  value="${list.valueId}">${list.valueName}</option>
						</#if>
						
						</#list>
						</select>
						&nbsp;&nbsp;&nbsp;&nbsp;
						
						<div class="input-group">
							<input type="submit" class="btn btn-primary" name="" id="" value="查询" />
						</div>
					</form>
					<!--添加 start-->
				
					<ul class="list-inline">
					<li class="margin-top pull-right">
						<button class="btn btn-primary add" data-toggle="modal" data-target="#modal-add" data-backdrop="static">
							<span class="glyphicon glyphicon-plus"></span>&nbsp;添加
						</button> <!--添加模态框--> <!--添加模态框-->
					</li>
					</ul>
				
					<!--添加 end-->
					<!--查询-->
					<div class="space_hx ">&nbsp;</div>
					<!--列表-->
					<table class="col-md-11 table table-hover text-center">
						<tr class="bg-hui ">
							<td>编号</td>
							<td>优惠卷金额</td>
							<td>所需积分</td>
							<td>优惠卷类型</td>
							<td>优惠卷名称</td>
							<td>使用规则</td>
							<td>注意事项</td>
							<td>操作</td>							
						</tr>
				
					
					<#list grabList as list>
					<tr>
					<td>${list.grabId}</td>
					<td>${list.theVolumeof}</td>
					<td>${list.theIntegral}</td>
					<td>${list.valueName}</td>
					<td>${list.carRental}</td>
					<#if list.useRules ?length gt 15>
					<td>${list.useRules ?substring(0,10)}<span style="font-size: 18px">...</span></td>
					<#else>
					<td>${list.useRules}</td>
					</#if>
					
					<#if list.mattersNeedingAttention ?length gt 15>
					<td>${list.mattersNeedingAttention ?substring(0,10)}<span style="font-size: 18px">...</span></td>
					<#else>
					<td>${list.mattersNeedingAttention}</td>
					</#if>
					
					
					<td>
								<span class="glyphicon glyphicon-edit bianji" data-toggle="modal" data-target=".mymodal" data-backdrop="static"></span> &nbsp;
								
								<a class="removes" href="javaScript:;"><span class="glyphicon glyphicon-remove color-red "></span></a>
								
							</td>
							</tr>
					</#list>
					
					
					
					</table>
					<!--列表-->
					<!--右边底部-->
					<div class="r_foot ">
					<div class="r_foot_m ">
						<!--分页-->
						<div class="page ">
							<input type="hidden" id="thisPageNo"/>
					
						</div>
						<!--分页-->
					</div>
				</div>
					</form>
					<!--右边底部-->
				</div>
				<!--会议列表-->
			</div>
		</div>
		<!-- 添加模态框-->
		<div id="modal-add" class="modal fade">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" data-dismiss="modal">&times;</button>
						<!--head-text 标题信息-->
						<h4 class="head-text text-left">添加优惠卷</h4>
					</div>
					<div class="modal-body">
						<form action="" class="form-horizontal addgrab" method="post">
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷金额：</span>
								<div class="col-md-6">
									<input type="text" class="form-control storadeName" name="theVolumeof" id="" value="" />
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">所需积分：</span>
								<div class="col-md-6">
									<input type="text" class="form-control storadeAdress" name="theIntegral" id="" value="" />
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷类型：</span>
								<div class="col-md-6">
									<select class="form-control testselect classifyId" name="couponId">
										<option value="0">请选择优惠卷类型</option>
									<#list codeList as list>
										<option value="${list.valueId}">${list.valueName}</option>
									</#list>
									</select>
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷名称</span>
								<div class="col-md-6">
										<input type="text" class="form-control " name="carRental" id="" value="" />
								</div>
							</div>
						
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">使用规则：</span>
								<div class="col-md-9">
									<input type="text" class="form-control " name="useRules" id="" value="①租期>=2天时可用，每单限用1张，限本人使用；<br>
②不与顺风车、预付特价、套餐产品同享，不与其他优惠活动、优惠类电子券同时享用；<br>
③代金券不可转让、不开发票、不找零、不兑换现金；<br>" />
								</div>
							</div>
							
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">注意事项：</span>
								<div class="col-md-9">
									<input type="text" class="form-control " name="mattersNeedingAttention" id="" value="1.优惠券请在有效期内使用，代金券不可兑换、找零、开具发票、转让；<br>
2.已兑换商品的对应积分不可退回；<br>
3.积分兑换记录可在积分明细中查询；<br>
4.兑换成功后，可在兑换记录中查询，或在神州租车平台“钱包—优惠券”中查看。" />
								</div>
							</div>
						
					</div>
					<div class="modal-footer">
						<button class="btn btn-default" data-dismiss="modal">关闭</button>
						<input type="button" value="保存" class="btn btn-primary addlist"/>
					</div>
					</form>
				</div>
			</div>
		</div>
		<#if codeId??>
		<span class="codeIds" style="display: none;">${codeId}</span>
		</#if>
		
		<!--模态框-->
		<!-- 修改模态框-->
		<div class="modal fade mymodal">
			<div class="modal-dialog modal-lg">
				<div class="modal-content">
					<div class="modal-header">
						<button class="close" data-dismiss="modal">&times;</button>
						<!--head-text 标题信息-->
						<h4 class="head-text text-left">优惠卷详情</h4>
					</div>
					<div class="modal-body">
						<form action="" class="form-horizontal update" method="post">
						
						<input type="hidden" class="grabId" name="grabId" value=""/>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷金额：</span>
								<div class="col-md-6">
									<input type="text" class="form-control rackCount" name="theVolumeof" id="" value="" />
								</div>
							</div>
							
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">所需积分：</span>
								<div class="col-md-6">
									<input type="text" class="form-control rackCounts" name="theIntegral" id="" value="" />
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷类型：</span>
								<div class="col-md-6">
									<select class="form-control testselect couponId" name="couponId">
										<option value="0">请选择优惠卷类型</option>
										<#list codeList as list>
						<option value="${list.valueId}">${list.valueName}</option>
						</#list>
									</select>
									<!-- <input type="text" class="form-control classifyName" name="classifyName" id="" value="" /> -->
								</div>
							</div>
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">优惠卷名称：</span>
								<div class="col-md-6">
								<input type="text" class="form-control carRentals" name="carRental" id="" value="" />
								<!-- <input type="text" class="form-control userName" name="userName" id="" value="" /> -->
								</div>
							</div>
						
							<div class="form-group">
								<span class="col-md-2 text-center margin-top">使用规则：</span>
								<div class="col-md-9">
									<input type="text" class="form-control useRuless" name="useRules" id="" value="" />
								</div>
								
							</div>
								<div class="form-group">
								<span class="col-md-2 text-center margin-top">注意事项：</span>
								<div class="col-md-9">
									<input type="text" class="form-control mattersNeedingAttentions" name="mattersNeedingAttention" id="" value="" />
								</div>
								
							</div>
					</div>
					<div class="modal-footer">
						<button class="btn btn-default" data-dismiss="modal">关闭</button>
						
						<input type="button" value="保存" class="btn btn-primary updatelist"/>
					
					</div>
					</form>
				</div>
			</div>
		</div>
		<!--模态框-->
		
		<script type="text/javascript "
		src="/js/jquery-3.2.1.js "></script>
		<script type="text/javascript "
		src="/js/bootstrap.js "></script>
		
	<script type="text/javascript "
		src="/js/layer-v3.1.1/layer/layer.js "></script>
	
		
		<script type="text/javascript">
			$(function() {
				$(".glyphicon.glyphicon-edit.bianji").click(function(){
					var id=$(this).parents("tr").children("td").eq(0).html();
					$.ajax({
						type:"POST",
						dataType:"json",
						url:"/grab/selectGrab",
						data:{"id":id},
						async:true,
						success: function(data){
							$(".rackCount").val(data.theVolumeof)	
							$(".rackCounts").val(data.theIntegral)
							var numbers = $(".couponId").find("option");
							for (var i = 0; i < numbers.length; i++) {
								if($(numbers[i]).val()==data.couponId){
									$(numbers[i]).attr("selected","selected")
								}
							}
							$(".grabId").val(data.grabId)
							$(".carRentals").val(data.carRental)
							$(".useRuless").val(data.useRules)
							$(".mattersNeedingAttentions").val(data.mattersNeedingAttention)
						}
						
					})
				})
				
				
				$(".addlist").click(function(){
					var ouid = $(".classifyId").val();
					var theVolumeof = $("input[name='theVolumeof']").val().trim();
					var theIntegral = $("input[name='theIntegral']").val().trim();
					var carRental = $("input[name='carRental']").val().trim();
					if(ouid==0){layer.msg('请选择类型',{time:1500,})
						return false;
					}
					if(theVolumeof==""){layer.msg('请填写金额',{time:1500,})
						return false;
					}
					if(theIntegral==""){layer.msg('请填写积分',{time:1500,})
						return false;
					}
					if(carRental==""){layer.msg('请填写名称',{time:1500,})
						return false;
					}
					
					var datas = $(".addgrab").serializeArray();
					layer.load(1);
					$.ajax({
						type:"POST",
						dataType:"json",
						url:"/grab/addGrab",
						data:datas,
						async:true,
						success: function(data){
							if(data.msg){
								alert("添加成功")
								var codeId = $(".codeIds").text().trim();
								location.href="/jump/selectGrabtheAll?codeId="+codeId;
							}else{
								alert("失败！")
							}
						}
					})
				})
				
				$(".removes").click(function(){
					var id=$(this).parents("tr").children("td").eq(0).html();
					parent.layer.confirm('您确定要删除么？', {
					    btn: ['确定','返回'], //按钮
					    shade: false //不显示遮罩
					}, function(index){
						layer.load(1);
						parent.layer.close(index)
						$.ajax({
							type:"get",
							dataType:"json",
							url:"/grab/delGrab",
							data:{"id":id},
							async:true,
							success: function(data){
								
								if(data.msg){
									alert("刪除成功")
									
									var codeId = $(".codeIds").text().trim();
									location.href="/jump/selectGrabtheAll?codeId="+codeId;
								}else{
									alert("失败！")
								}
							}
						})
					}, function(){
					  
					});
					
				})
				
				//修改
				$(".updatelist").click(function(){
					
					var theVolumeof = $(".mymodal").find("input[name='theVolumeof']").val().trim();
					var theIntegral = $(".mymodal").find("input[name='theIntegral']").val().trim();
					var carRental = $(".mymodal").find("input[name='carRental']").val().trim();
					
					if(theVolumeof==""){layer.msg('请填写金额',{time:1500,})
						return false;
					}
					if(theIntegral==""){layer.msg('请填写积分',{time:1500,})
						return false;
					}
					if(carRental==""){layer.msg('请填写名称',{time:1500,})
						return false;
					}
					
					var datas = $(".update").serializeArray();
					layer.load(1);
					$.ajax({
						type:"get",
						dataType:"json",
						url:"/grab/updGrab",
						data:datas,
						async:true,
						success: function(data){
							if(data.msg){
								alert("修改成功")
								var codeId = $(".codeIds").text().trim();
								location.href="/jump/selectGrabtheAll?codeId="+codeId;
							}else{
								alert("失败！")
							}
						}
					})
				})
			
			})
		</script>
	</body>

</html>